{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9166d3ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "def calXnew(xold,A,b):\n",
    "    return A @ xold + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ffb31deb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4c4e99d4",
   "metadata": {},
   "outputs": [],
   "source": [
    "A = np.array([\n",
    "    [0,-2/3],\n",
    "    [-1/3,0]\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "637dd783",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.        , -0.66666667],\n",
       "       [-0.33333333,  0.        ]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "a53e1add",
   "metadata": {},
   "outputs": [],
   "source": [
    "b = np.array([2,1/3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a67e0f23",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2.        , 0.33333333])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1d28563d",
   "metadata": {},
   "outputs": [],
   "source": [
    "Xold = np.array([1,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "68b1db39",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1.33333333, 0.        ])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "calXnew(Xold,A,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "27c7991c",
   "metadata": {},
   "outputs": [],
   "source": [
    "Xnew = calXnew(Xold,A,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "06e02760",
   "metadata": {},
   "outputs": [],
   "source": [
    "Xold = Xnew\n",
    "Xnew = calXnew(Xold,A,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "81206b83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2.        , -0.11111111])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Xnew"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9f761ea2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 [ 2.         -0.11111111]\n",
      "1 [ 2.07407407 -0.33333333]\n",
      "2 [ 2.22222222 -0.35802469]\n",
      "3 [ 2.23868313 -0.40740741]\n",
      "4 [ 2.27160494 -0.41289438]\n",
      "5 [ 2.27526292 -0.42386831]\n",
      "6 [ 2.28257888 -0.42508764]\n",
      "7 [ 2.28339176 -0.42752629]\n",
      "8 [ 2.28501753 -0.42779725]\n",
      "9 [ 2.28519817 -0.42833918]\n"
     ]
    }
   ],
   "source": [
    "for i in range(10):\n",
    "    Xnew = calXnew(Xold,A,b)\n",
    "    Xold = Xnew\n",
    "    print(i, Xnew)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "6be42fdc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2.28571429, -0.42857143])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linalg.inv([[3,2],[1,3]]) @ np.array([6,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "fe3f9c80",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\dell\\AppData\\Local\\Temp/ipykernel_5696/2506215629.py:3: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.\n",
      "  A = np.array([\n"
     ]
    }
   ],
   "source": [
    "n = 4\n",
    "\n",
    "A = np.array([\n",
    "    [1,2,1,3],\n",
    "    [1,3,1,1],\n",
    "    [-1,2,5,1],\n",
    "    [0,1,-1.5]\n",
    "])\n",
    "b = np.array([1,2,3,4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "b0989a43",
   "metadata": {},
   "outputs": [],
   "source": [
    "A = np.random.rand(n,n)\n",
    "b = np.random.rand(n,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2f8e2a39",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "e44ba6db",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.60597509, 0.20990535, 0.54548514, 0.11096957],\n",
       "       [0.48402412, 0.71479181, 0.34305019, 0.90727938],\n",
       "       [0.49475573, 0.60152866, 0.70028363, 0.13497593],\n",
       "       [0.32041925, 0.46980787, 0.7205808 , 0.83442004]])"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "2d5730e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.52169282],\n",
       "       [0.44664265],\n",
       "       [0.45587913],\n",
       "       [0.23024861]])"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "3f01d463",
   "metadata": {},
   "outputs": [],
   "source": [
    "diag = np.diag(A)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "714098ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "D = np.diag(diag)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "da746907",
   "metadata": {},
   "outputs": [],
   "source": [
    "L = np.tril(A,-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "77044abc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.        , 0.        , 0.        , 0.        ],\n",
       "       [0.48402412, 0.        , 0.        , 0.        ],\n",
       "       [0.49475573, 0.60152866, 0.        , 0.        ],\n",
       "       [0.32041925, 0.46980787, 0.7205808 , 0.        ]])"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "L"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "f1f5c63c",
   "metadata": {},
   "outputs": [],
   "source": [
    "U = np.triu(A,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "9b9a08ca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.        , 0.20990535, 0.54548514, 0.11096957],\n",
       "       [0.        , 0.        , 0.34305019, 0.90727938],\n",
       "       [0.        , 0.        , 0.        , 0.13497593],\n",
       "       [0.        , 0.        , 0.        , 0.        ]])"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "U"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "85e84b28",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr_A = - np.linalg.inv(D)@(L+U)\n",
    "vac_b = - np.linalg.inv(D)@ b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "1ea3217a",
   "metadata": {},
   "outputs": [],
   "source": [
    "Xold = np.array([1,1,1,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "0fd10ad7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 [[-2.29061044 -3.28729059 -2.61914553 -2.671523  ]\n",
      " [-2.0545528  -3.05123295 -2.38308789 -2.43546537]\n",
      " [-2.08068796 -3.07736811 -2.40922305 -2.46160052]\n",
      " [-1.70563431 -2.70231447 -2.03416941 -2.08654688]]\n",
      "1 [[2.03610129 3.46105075 2.50580655 2.5806904 ]\n",
      " [4.08977162 6.50809241 4.88692128 5.01400872]\n",
      " [3.06091046 4.81330432 3.63855102 3.73064271]\n",
      " [3.55726828 5.36186573 4.15211668 4.24695177]]\n",
      "2 [[ -5.68437134  -8.42999355  -6.58940918  -6.73369694]\n",
      " [ -7.98784588 -12.08434355  -9.338172    -9.55345089]\n",
      " [ -6.28818408  -9.72003412  -7.4194228   -7.59977317]\n",
      " [ -6.00380459  -9.42590451  -7.13182938  -7.31166736]]\n",
      "3 [[ 8.66594915 13.80089438 10.35857813 10.62842945]\n",
      " [13.86280705 21.71270788 16.45036526 16.86289275]\n",
      " [11.3836497  17.50184815 13.40038787 13.72191105]\n",
      " [11.83460429 18.15904769 13.91932686 14.25168861]]\n",
      "4 [[-18.07741435 -27.4621949  -21.17091407 -21.66410246]\n",
      " [-26.97796234 -41.41898325 -31.7381476  -32.49705122]\n",
      " [-20.96246299 -32.55224067 -24.78279462 -25.39185988]\n",
      " [-21.23951965 -32.91461897 -25.08797579 -25.70152488]]\n",
      "5 [[31.24349232 48.81662344 37.03611323 37.95961531]\n",
      " [48.63600317 75.37233676 57.44908514 58.85413126]\n",
      " [39.38813593 60.67339628 46.40438382 47.52296548]\n",
      " [39.95794539 61.70112036 47.12513541 48.26778137]]\n",
      "6 [[ -60.4817083   -92.88522392  -71.16286016  -72.86572767]\n",
      " [ -91.40336033 -141.11694884 -107.79042137 -110.40296674]\n",
      " [ -72.2037254  -111.77609645  -85.24794288  -87.32754762]\n",
      " [ -73.67174052 -113.85469134  -86.91722304  -89.02891494]]\n",
      "7 [[109.2878943  169.48900426 129.13195089 132.29563583]\n",
      " [168.49425664 260.43229192 198.79973732 203.63125916]\n",
      " [134.79316329 208.13445323 158.9686097  162.82283655]\n",
      " [136.76552097 211.37259324 161.35820648 165.27895263]]\n",
      "8 [[-205.6091386  -317.13844823 -242.37247957 -248.23356081]\n",
      " [-312.91625298 -483.57851881 -369.17155564 -378.14018827]\n",
      " [-248.95751144 -384.84297654 -293.74935766 -300.89040205]\n",
      " [-253.51438999 -391.73150741 -299.0748174  -306.33839464]]\n",
      "9 [[378.0619211  584.81021766 446.21224092 457.07726437]\n",
      " [579.8701529  896.0460603  684.09103194 700.70668829]\n",
      " [462.2653496  714.29750694 545.34256191 558.58733995]\n",
      " [469.85376725 726.11687298 554.32562459 567.79274717]]\n",
      "10 [[ -703.88683146 -1087.20987501  -830.24138164  -850.38575005]\n",
      " [-1074.86762479 -1661.09855779 -1268.10658364 -1298.91415467]\n",
      " [ -856.41249315 -1323.4634324  -1010.36622051 -1034.91065202]\n",
      " [ -871.13879023 -1346.19641004 -1027.73175501 -1052.69695309]]\n",
      "11 [[1301.91647175 2012.40655525 1536.11490155 1573.45253162]\n",
      " [1992.76245017 3079.46976434 2350.97314521 2408.08171946]\n",
      " [1587.84608543 2453.79139851 1873.28713144 1918.79423493]\n",
      " [1614.77942646 2495.37660037 1905.05015677 1951.32724393]]\n",
      "12 [[-2416.19008257 -3733.38195329 -2850.37526689 -2919.59625103]\n",
      " [-3693.90434335 -5708.34360587 -4357.92277678 -4463.78546188]\n",
      " [-2943.4453668  -4548.6007853  -3472.5518066  -3556.90583294]\n",
      " [-2993.42791185 -4625.91736834 -3531.54445458 -3617.33493756]]\n",
      "13 [[ 4476.47721685  6918.13970675  5281.32099232  5409.63508553]\n",
      " [ 6847.68968452 10582.09943558  8078.66098199  8274.91144775]\n",
      " [ 5456.35784228  8431.97783498  6437.20971644  6593.58431067]\n",
      " [ 5549.21850143  8575.38890763  6546.73327876  6705.76439513]]\n",
      "14 [[ -8300.74527054 -12827.07304342  -9792.75604139 -10030.6233331 ]\n",
      " [-12694.13764313 -19616.70228069 -14976.01856723 -15339.81274755]\n",
      " [-10114.91757967 -15631.02708444 -11933.18952268 -12223.07176156]\n",
      " [-10286.69558715 -15896.56253053 -12135.8727397  -12430.68211357]]\n",
      "15 [[15385.27441925 23775.98829798 18151.10051722 18592.0487839 ]\n",
      " [23531.53056211 36364.45704774 27761.64059807 28436.03574156]\n",
      " [18750.58737224 28976.07940524 22121.21031782 22658.57973037]\n",
      " [19069.42398933 29468.74339639 22497.34555034 23043.84992809]]\n",
      "16 [[-28522.96826683 -44077.33998434 -33650.14669951 -34467.55906122]\n",
      " [-43622.46121377 -67411.55974399 -51464.04781927 -52714.2110252 ]\n",
      " [-34759.07608391 -53714.80224489 -41007.44098822 -42003.60111418]\n",
      " [-35349.79804828 -54627.67801075 -41704.35432136 -42717.44425357]]\n",
      "17 [[ 52872.43308389  81706.59505123  62377.02099321  63892.31205477]\n",
      " [ 80864.95557639 124964.34059791  95401.41001396  97718.91811492]\n",
      " [ 64435.29012006  99574.6078971   76018.24284342  77864.88205552]\n",
      " [ 65530.51674661 101267.14432565  77310.36034991  79188.38934906]]\n",
      "18 [[ -98015.40605899 -151467.02639713 -115634.63234255 -118443.61852416]\n",
      " [-149905.19224704 -231654.98775451 -176852.32942584 -181148.43952459]\n",
      " [-119447.35361322 -184587.38213051 -140919.42303418 -144342.65770541]\n",
      " [-121477.6687961  -187724.85112481 -143314.68867901 -146796.10642752]]\n",
      "19 [[181694.69688172 280781.37359615 214356.58005145 219563.77683822]\n",
      " [277887.89803016 429432.54735757 327841.47196619 335805.43682197]\n",
      " [221427.5085931  342181.60347663 261231.61011443 267577.47169457]\n",
      " [225191.02218604 347997.61187037 265671.68636557 272125.41052307]]\n"
     ]
    }
   ],
   "source": [
    "for i in range(20):\n",
    "    Xnew = calXnew(Xold,arr_A,vac_b)\n",
    "    Xold = Xnew\n",
    "    print(i, Xnew)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "dacc76ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.91634635],\n",
       "       [ 0.13594861],\n",
       "       [-0.10053362],\n",
       "       [-0.06566661]])"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linalg.inv(A)@ b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "5659253d",
   "metadata": {},
   "outputs": [],
   "source": [
    "w = 1.2\n",
    "arr_A = np.linalg.inv(w * L + D) @ ((1 - w) * D - w * U)\n",
    "vec_b = np.linalg.inv(w * L + D) @ (w * b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "cad22db0",
   "metadata": {},
   "outputs": [],
   "source": [
    "Xold = np.array([1,1,1,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "d60a9b49",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 [[-2.7765496  -1.60336519  1.09718369 -1.70570154]\n",
      " [-2.54049196 -1.36730755  1.33324132 -1.4696439 ]\n",
      " [-2.56662712 -1.39344271  1.30710616 -1.49577906]\n",
      " [-2.19157347 -1.01838906  1.68215981 -1.12072541]]\n",
      "1 [[ 4.00450862  1.75711552 -3.41615037  1.95315461]\n",
      " [ 0.74593028 -0.12510116 -2.13012521 -0.04912147]\n",
      " [-5.16869256 -2.87148216  2.416458   -3.07186679]\n",
      " [ 1.67583886  0.68474801 -1.59664035  0.77120042]]\n",
      "2 [[ 3.24314389  1.79100167 -1.55167916  1.91767138]\n",
      " [-3.68475863 -2.14398433  1.40271835 -2.27838538]\n",
      " [-0.33025474 -0.91751498 -2.26932716 -0.86628853]\n",
      " [-0.76724442 -0.3323183   0.66883654 -0.37025671]]\n",
      "3 [[ 0.5474528   0.73621647  1.17073088  0.7197507 ]\n",
      " [ 0.32650435 -0.45928206 -2.26808092 -0.39073827]\n",
      " [-2.58214812 -1.9153588  -0.38047892 -1.97352253]\n",
      " [ 0.58697878  0.25293747 -0.515991    0.28207574]]\n",
      "4 [[ 1.55415727  1.19616469  0.3721029   1.22739222]\n",
      " [-2.05956423 -1.48672737 -0.1681163  -1.53669567]\n",
      " [-0.83898761 -1.18204001 -1.97171106 -1.1521157 ]\n",
      " [-0.34204041 -0.14180091  0.31912967 -0.15926771]]\n",
      "5 [[ 0.6658045   0.82585808  1.19428483  0.81189668]\n",
      " [-0.44936734 -0.8014172  -1.61179946 -0.77070804]\n",
      " [-1.87933954 -1.62985411 -1.05556453 -1.65161661]\n",
      " [ 0.2433029   0.10882361 -0.20073376  0.12055418]]\n",
      "6 [[ 1.16933455  1.04371536  0.75455301  1.05467306]\n",
      " [-1.47297773 -1.23934209 -0.70153706 -1.25972202]\n",
      " [-1.17844138 -1.33155879 -1.6840192  -1.31820243]\n",
      " [-0.14052963 -0.05492894  0.14211499 -0.06239585]]\n",
      "7 [[ 0.82134213  0.89593895  1.0676531   0.88943191]\n",
      " [-0.80450639 -0.95404966 -1.29828277 -0.94100507]\n",
      " [-1.62385495 -1.52212886 -1.28796595 -1.53100238]\n",
      " [ 0.10652067  0.05064664 -0.07796958  0.05552051]]\n",
      "8 [[ 1.03992834  0.98956233  0.873625    0.99395574]\n",
      " [-1.23559426 -1.13824013 -0.91414101 -1.14673228]\n",
      " [-1.33287846 -1.39794975 -1.54773712 -1.39227361]\n",
      " [-0.05388791 -0.01784847  0.06511058 -0.02099218]]\n",
      "9 [[ 0.89633525  0.9283123   1.00192015  0.92552296]\n",
      " [-0.95594686 -1.01881962 -1.16354617 -1.01333525]\n",
      " [-1.52048611 -1.47811035 -1.38056577 -1.48180677]\n",
      " [ 0.04983529  0.02645842 -0.02735271  0.02849757]]\n",
      "10 [[ 0.98867545  0.96777669  0.91966989  0.96959968]\n",
      " [-1.1368503  -1.09609213 -1.00227106 -1.09964745]\n",
      " [-1.39877134 -1.42613387 -1.4891196  -1.42374705]\n",
      " [-0.01736516 -0.00224213  0.03256952 -0.0035613 ]]\n",
      "11 [[ 0.92869324  0.94216507  0.97317581  0.94098993]\n",
      " [-1.01967013 -1.04604488 -1.10675682 -1.04374422]\n",
      " [-1.4775041  -1.45976458 -1.41893003 -1.46131199]\n",
      " [ 0.02613261  0.01633684 -0.006212    0.01719132]]\n",
      "12 [[ 0.96747075  0.95872977  0.93860895  0.95949224]\n",
      " [-1.09552633 -1.07844464 -1.03912438 -1.07993467]\n",
      " [-1.42650361 -1.43798249 -1.4644057  -1.4369812 ]\n",
      " [-0.00203512  0.00430619  0.01890323  0.00375304]]\n",
      "13 [[ 0.94234497  0.94799893  0.96101377  0.94750574]\n",
      " [-1.04640659 -1.05746514 -1.08292079 -1.05650051]\n",
      " [-1.45951819 -1.45208373 -1.43497036 -1.45273223]\n",
      " [ 0.0162016   0.01209538  0.00264328  0.01245356]]\n",
      "14 [[ 0.95860771  0.95494518  0.94651442  0.95526466]\n",
      " [-1.07820902 -1.07104843 -1.0545655  -1.07167305]\n",
      " [-1.43813988 -1.44295286 -1.45403183 -1.44253302]\n",
      " [ 0.00439338  0.00705195  0.01317169  0.00682005]]\n",
      "15 [[ 0.94807625  0.95044713  0.95590463  0.95024032]\n",
      " [-1.05761727 -1.06225344 -1.07292544 -1.06184903]\n",
      " [-1.45198117 -1.44886468 -1.44169084 -1.44913653]\n",
      " [ 0.01203881  0.01031742  0.00635495  0.01046757]]\n",
      "16 [[ 0.95489459  0.95335935  0.94982537  0.95349327]\n",
      " [-1.0709498  -1.06794795 -1.06103799 -1.0682098 ]\n",
      " [-1.44301906 -1.44503685 -1.4496816  -1.44486084]\n",
      " [ 0.00708854  0.00820309  0.01076867  0.00810587]]\n",
      "17 [[ 0.95047972  0.9514737   0.95376175  0.951387  ]\n",
      " [-1.06231726 -1.06426088 -1.06873488 -1.06409134]\n",
      " [-1.44882175 -1.44751526 -1.44450785 -1.44762922]\n",
      " [ 0.01029371  0.00957206  0.0079109   0.00963501]]\n",
      "18 [[ 0.9533382   0.9526946   0.95121311  0.95275074]\n",
      " [-1.06790662 -1.06664817 -1.06375135 -1.06675794]\n",
      " [-1.44506463 -1.44591054 -1.44785775 -1.44583675]\n",
      " [ 0.00821844  0.00868569  0.00976125  0.00864493]]\n",
      "19 [[ 0.95148739  0.95190409  0.95286332  0.95186774]\n",
      " [-1.06428764 -1.06510245 -1.06697807 -1.06503138]\n",
      " [-1.44749727 -1.44694955 -1.44568878 -1.44699733]\n",
      " [ 0.00956213  0.00925959  0.0085632   0.00928598]]\n"
     ]
    }
   ],
   "source": [
    "for i in range(20):\n",
    "    Xnew = calXnew(Xold,arr_A,vac_b)\n",
    "    Xold = Xnew\n",
    "    print(i, Xnew)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "498ccd25",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
